# encoding: utf-8
"""
@author: 夏洛
@QQ: 1972386194
@file: 02-etst.py
"""

from PIL import Image
image_ori = Image.open('image/bg.png')
image_gap = Image.open('image/qk.png')

gap_pos = []
for i in range(image_ori.size[0]):
    if gap_pos:
        break
    for j in range(image_ori.size[1]):
        # 用来获取图像中某一点的像素的RGB颜色值,getpixel的参数是一个坐标点
        pixel_ori = image_ori.getpixel((i, j))
        pixel_gap = image_gap.getpixel((i, j))
        # abs() 函数返回数字的绝对值
        if abs(pixel_ori[0] - pixel_gap[0]) > 10 and abs(pixel_ori[1] - pixel_gap[1]) > 10 and abs(
                pixel_ori[2] - pixel_gap[2]) > 10:
            gap_pos = [i, j]
            break
distance = gap_pos[0]  # 返回缺口距离   减去边缘
print(distance)
